//
//  CustomNavigationBar.m
//  CustomNavigationBar
//
//  Created by George on 10/27/10.
//  Copyright 2010 RED/SAFI. All rights reserved.
//

#import "CustomNavigationBar.h"

@implementation UINavigationBar (UINavigationBarCategory)

-(void)setBackgroundImage:(UIImage*)image
{
    if(image == nil)
	{
		[backgroundView removeFromSuperview];
	}
	else
	{
		backgroundView = [[UIImageView alloc] initWithImage:image];
		backgroundView.frame = CGRectMake(0.f, 0.f, 320, 44);
		backgroundView.autoresizingMask  = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
		[self addSubview:backgroundView];
		[self sendSubviewToBack:backgroundView];
		[backgroundView release];
	}
}


//for other views
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index
{
    [super insertSubview:view atIndex:index];
    [self sendSubviewToBack:backgroundView];
}

@end